package com.heima.admin.controller.v1;

import com.heima.admin.service.AdUserService;
import com.heima.apis.admin.LoginControllerApi;
import com.heima.model.admin.dtos.AdUserDto;
import com.heima.model.admin.pojos.AdUser;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/login")
@Api(value = "登录系统和注册系统",tags = "登录-Login",description = "登录系统测试")
public class LoginController implements LoginControllerApi {

    @Autowired
    private AdUserService adUserService;

    @PostMapping("/in")
    @Override
    @ApiOperation("登录页面")
    public ResponseResult login(@RequestBody AdUserDto dto) {
        return adUserService.login(dto);
    }

    /**
     * 实现注册功能
     *
     * @param adUser 新增的用户
     * @return
     */
    @Override
    @PostMapping("/register")
    @ApiOperation("注册页面")
    public ResponseResult register(AdUser adUser) {
        return adUserService.register(adUser);
    }
}